package com.yy.controller;

import com.yy.clientEntities.TestData;
import com.yy.service.FeignService;
import com.yy.utils.Result;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Collection;

/**
 * Author young
 * Date 2023/1/4 22:07
 * Description: SpringCloudAlibaba
 */
@RestController
@RequestMapping("feign")
public class ConsumerController {
    @Resource
    private FeignService feignService;


    @GetMapping("find/{id}")
   public Result<TestData> findOne(@PathVariable("id") Integer id){
      return feignService.findOne(id);
    }

    @GetMapping("all")
    Result<Collection<TestData>> all() {
        return feignService.all();
    }

    @PutMapping("add")
    Result<String> add(@RequestBody TestData testData){
        return feignService.add(testData);
    }

    @PostMapping("update")
    Result<TestData> update(@RequestBody TestData testData){
        return feignService.update(testData);
    }

    @DeleteMapping("delete/{id}")
    Result<String> delete(@PathVariable("id") Integer id){
        return feignService.delete(id);
    }
}
